package com.wn.ziroom.controller;


import com.wn.ziroom.entity.Areas;
import com.wn.ziroom.entity.Cities;
import com.wn.ziroom.service.AreasService;
import com.wn.ziroom.service.CitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Controller
@RequestMapping("/areas")
public class AreasController {


    private AreasService areasService;
    private CitiesService citiesService;

    @Autowired
    public void setAreasService(AreasService areasService) {
        this.areasService = areasService;
    }

    @Autowired
    public void setCitiesService(CitiesService citiesService) {
        this.citiesService = citiesService;
    }

    @ResponseBody
    @RequestMapping("/getAreas")
    public List<Areas> getAreas(){
        List<Areas> areasList = areasService.getShangHaiArea();
        return areasList;
    }

    @ResponseBody
    @PostMapping("/showAreas")
    public List<Areas> showAreas(@RequestParam("cityName") String cityName){
        System.out.println("cityName-------------->"+cityName);
        /*Cities city = citiesService.findCityByName(cityName);
        String cityCode = city.getCode();*/
        List<Areas> areasList = areasService.findListByCityCode(cityName);
        return areasList;
    }

}

